<template>
  <div>
    <a-table :columns="columns" :dataSource="userList" bordered rowKey>
      <a slot="edit" @click="editBtn">编辑用户</a>
      <!-- <a slot="edit" v-else @click="editBtn">添加用户</a> -->
    </a-table>
  </div>
</template>

<script>
export default {
  name: 'userDetail',
  data () {
    return {
      columns: [
        {
          title: '人员ID',
          dataIndex: 'user_id',
          key: 'user_id'
        },
        {
          title: '姓名',
          dataIndex: 'name',
          key: 'name'
        },
        {
          title: '年龄',
          dataIndex: 'age',
          key: 'age'
        },
        {
          title: 'Email',
          dataIndex: 'email',
          key: 'email'
        },
        {
          title: '手机号',
          dataIndex: 'tel',
          key: 'tel'
        },
        {
          title: '操作',
          dataIndex: 'edit',
          key: 'edit',
          scopedSlots: { customRender: 'edit' }
        }
      ],
      userList: [
        {
          user_id: '',
          name: '',
          email: '',
          age: '',
          tel: ''
        }
      ]
    }
  },
  methods: {
    editBtn () {
      this.$router.push('/dashboard/userEdit')
    },
    setTableData () {
      this.userList = [{
        user_id: this.$store.state.editUserInfo.user_id,
        name: this.$store.state.editUserInfo.name,
        email: this.$store.state.editUserInfo.email,
        age: this.$store.state.editUserInfo.age,
        tel: this.$store.state.editUserInfo.tel
      }]
      console.log(this.userList)
    }
  },
  mounted () {
    this.setTableData()
    // console.log('created')
  }

}
</script>

<style lang="less" scope>
</style>
